home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyc (Python 2.6)
-
- import optparse
- import sys
- import gmenu
-
- def print_entry(entry, path):
- if entry.get_is_excluded():
- excluded = ' <excluded>'
- else:
- excluded = ''
- print '%s\t%s\t%s%s' % (path, entry.get_desktop_file_id(), entry.get_desktop_file_path(), excluded)
-
-
- def print_directory(dir, parent_path = None):
- if not parent_path:
- path = '/'
- else:
- path = '%s%s/' % (parent_path, dir.get_name())
- for item in dir.get_contents():
- type = item.get_type()
- if type == gmenu.TYPE_ENTRY:
- print_entry(item, path)
- continue
- if type == gmenu.TYPE_DIRECTORY:
- print_directory(item, path)
- continue
- if type == gmenu.TYPE_ALIAS:
- aliased = item.get_item()
- if aliased.get_type() == gmenu.TYPE_ENTRY:
- print_entry(aliased, path)
-
- aliased.get_type() == gmenu.TYPE_ENTRY
- if type in [
- gmenu.TYPE_HEADER,
- gmenu.TYPE_SEPARATOR]:
- continue
- print >>sys.stderr, 'Unsupported item type: %s' % type
-
-
-
- def main(args):
- parser = optparse.OptionParser()
- parser.add_option('-f', '--file', dest = 'file', help = 'Menu file')
- parser.add_option('-i', '--include-excluded', dest = 'exclude', action = 'store_true', default = False, help = 'Include <Exclude>d entries')
- parser.add_option('-n', '--include-nodisplay', dest = 'nodisplay', action = 'store_true', default = False, help = 'Include NoDisplay=true entries')
- (options, args) = parser.parse_args()
- if options.file:
- menu_file = options.file
- else:
- menu_file = 'applications.menu'
- flags = gmenu.FLAGS_NONE
- if options.exclude:
- flags |= gmenu.FLAGS_INCLUDE_EXCLUDED
-
- if options.nodisplay:
- flags |= gmenu.FLAGS_INCLUDE_NODISPLAY
-
- tree = gmenu.lookup_tree(menu_file, flags)
- root = tree.get_root_directory()
- if not root:
- print 'Menu tree is empty'
- else:
- print_directory(root)
-
- if __name__ == '__main__':
-
- try:
- main(sys.argv)
- except KeyboardInterrupt:
- pass
- except:
- None<EXCEPTION MATCH>KeyboardInterrupt
-
-
- None<EXCEPTION MATCH>KeyboardInterrupt
-